package ua.kharkov.knure.mikhaylov.st4.db.entities;

import java.io.Serializable;

import ua.kharkov.knure.mikhaylov.st4.db.enums.Role;

/**
 * User db entity
 * 
 * @author Saint
 *
 */
public class User implements Serializable {

	private static final long serialVersionUID = 8301785743148248151L;

	private long id;
	private String login;
	private String password;
	private String firstName;
	private String lastName;
	private Role role;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	@Override
	public String toString() {
		return "User [login=" + login + ", firstName=" + firstName
				+ ", lastName=" + lastName + ", role=" + role.getName() + "]";
	}

	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof User))
			return false;
		User other = (User) obj;
		return (id == other.id && login.equals(other.login)
				&& password.equals(other.password)
				&& firstName.equals(other.firstName)
				&& lastName.equals(other.lastName) && role.equals(other.role));
	}
}
